package chap01;

/**
 *Output:
String: Testing
String: Scanner
int: 10
double: 12.2
String: one
boolean: true
String: two
boolean: false
 */

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class MainClass {
  public static void main(String args[]) throws IOException {

    int i;
    double d;
    boolean b;
    String str;
    int IntCount=0;
    int DoubleCount=0;   
    int BooleanCount=0;    
    int StringCount=0;    
    
    
 //   FileWriter fout = new FileWriter("test.txt");
 //   fout.write("Testing Scanner 10 12.2 one true two false");
 //   fout.close();

    FileReader fin = new FileReader("C:/LGSInst.Log");

    Scanner src = new Scanner(fin);

    while (src.hasNext()) {
      if (src.hasNextInt()) {
        //i = src.nextInt();
        //System.out.println("int: " + i);
    	  IntCount++;
      } else if (src.hasNextDouble()) {
        //d = src.nextDouble();
        //System.out.println("double: " + d);
    	  DoubleCount++;
      } else if (src.hasNextBoolean()) {
        //b = src.nextBoolean();
        //System.out.println("boolean: " + b);
    	  BooleanCount++;
      } else {
        //str = src.next();
        //System.out.println("String: " + str);
    	  StringCount++;
      }
    src.next();
    }
    System.out.println("int: " + IntCount);
    System.out.println("double: " + DoubleCount);
    System.out.println("boolean: " + BooleanCount);
    System.out.println("string: " + StringCount);
    
    fin.close();
  }
}